﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Maticsoft.Web.Admin.Shopping
{
    public partial class Delivery : PageBase
    {
        BLL.DeliveryWay bll = new BLL.DeliveryWay();
        string id = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            Check("shopping", "read");

            if (!string.IsNullOrEmpty(Request.QueryString["act"]) && Request.QueryString["act"]=="del")
            {
                id = Request.QueryString["id"];
            }

            if (!string.IsNullOrEmpty(id))
            {
                Del();
            }
            BindData();
        }

        protected void BindData()
        {
            DataSet ds = bll.GetAllList();
            Repeater1.DataSource = ds.Tables[0].DefaultView;
            Repeater1.DataBind();
        }

        protected void Del()
        {
            Model.DeliveryWay model = bll.GetModel(int.Parse(id));
            if (model.IsActive == 0)
            {
                model.IsActive = 1;
            }
            else
            {
                model.IsActive = 0;
            }
            model.UpdateTime = DateTime.Now;
            bll.Update(model);
        }
    }
}